import axios from "axios";
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
const request =axios.create({
    timeout:500
})
// 请求拦截器
request.interceptors.request.use((config) => {
    // 进度条开始
    Nprogress.start()
    // 处理临时标识及token

    
    return config
},
error=>{
    return Promise.reject(new Error('请求失败'))
}
)
// 响应拦截器
request.interceptors.response.use(
    (response) =>{
        // 进度条结束
        Nprogress.done()
       return response.data
    },
    (error)=>{
        // 进度条结束
        Nprogress.done()
        alert(error.message)
        return Promise.reject(error)
    }
)
export default request